/**
 * 文件名称 : AndroidFileIO.java
 * <p>
 * 作者信息 : maidou
 * <p>
 * 创建时间 : 2011-8-3, 上午4:24:41
 * <p>
 * 版权声明 : Copyright (c) 2009-2012 CIeNET Ltd. All rights reserved
 * <p>
 * 评审记录 :
 * <p>
 */

package com.ttomato.game.framework.impl;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

import android.content.res.AssetManager;
import android.os.Environment;

import com.ttomato.game.framework.FileIO;

/**
 * 请在这里增加文件描述
 * <p>
 */
public class AndroidFileIO implements FileIO
{
    AssetManager mAssets;
    
    String mExternalStoragePath;
    
    public AndroidFileIO(AssetManager assets)
    {
        mAssets = assets;
        
        mExternalStoragePath = Environment.getExternalStorageDirectory()
                .getAbsolutePath() + File.separator;
    }
    
    
    public InputStream readAsset(String fileName) throws Exception
    {
        // TODO Auto-generated method stub
        return mAssets.open(fileName);
    }
    
    
    public InputStream readFile(String fileName) throws Exception
    {
        // TODO Auto-generated method stub
        return new FileInputStream(mExternalStoragePath + fileName);
    }
    
    
    public OutputStream writeFile(String fileName) throws Exception
    {
        // TODO Auto-generated method stub
        return new FileOutputStream(mExternalStoragePath + fileName);
    }
    
}
